// pages/mine/order/detail/detail.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.orderId)
    const orderId = options.orderId
    const that = this;
    if(orderId == undefined){
      const goods = JSON.parse(options.goodsList)
      const that = this;
      that.setData({
        goods: goods
      })
    }else{
      wx.request({
        url: app.globalData.url + 'getOrderByOrderId',
        data: {
          orderId: orderId
        },
        header: {
          'content-type': 'application/json' // 默认值
        },
        success: function (res) {
          console.log(res.data.object)
          that.setData({
            mName: res.data.object[0].mName,
            goods: res.data.object,
            goodsAmount: res.data.object[0].goodsAmount,
            orderSn: res.data.object[0].orderSn,
            addTime: res.data.object[0].addTime,
          })
        },
        fail: function (res) { },
        complete: function (res) { },
      })
    }
  },
})